<!--  -->
<template>
  <div>
    <PageTitle name="考试信息"><el-button type="primary" @click="editFn()">开始考试</el-button></PageTitle>

    <Table
      :isSelection='true'
      :is-index="true"
      :loading="loading"
      :table-data="tableData"
      :table-cols="tableCols"
      :pagination="pagination"
      @pageChange="pageChange"
      @select = 'handleSelectionChange'
    ></Table>

  </div>
</template>

<script setup>
import {data} from "@/json/examination.json";

import { ElMessage, ElMessageBox } from "element-plus";
import { ref, reactive, getCurrentInstance, onMounted } from "vue";
const { proxy } = getCurrentInstance();
const loading = ref(false);
// 表格格式
const tableCols = [
  { label: "考试编号", prop: "exam_id" },
  { label: "考试简介", prop: "exam_subject" },
  { label: "截止时间", prop: "start_time" },
  { label: "所属课程", prop: "course" },
  {
    label: "操作",
    type: "Button",
    fixed: "right",
    btnList: [
      {
        type: "primary",
        label: "开始考试",
        handle: () => zy(),
      }
    ],
  },
];
const tableData = ref(data);
const pagination = reactive({
  pageIndex: 1,
  pageSize: 10,
});

const pageChange = (val) => {

};
let selectList = []
const handleSelectionChange = (val) => {
  selectList = val
};

const zy = (id) => {

  
  proxy.$msgbox
    .confirm("是否确定开始考试?", "提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    }).then(() => {
      proxy.$message({
            type: "success",
            message: "操作成功！",
          });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "取消操作！",
      });
    });

};
const editFn = (id) => {
  if(selectList&&selectList.length>0){

  
  proxy.$msgbox
    .confirm("是否确定开始所选考试?", "提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    }).then(() => {
      proxy.$message({
            type: "success",
            message: "操作成功！",
          });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "取消操作！",
      });
    });
    }else{
      proxy.$message({
            type: "error",
            message: "请选择需要开始的考试",
          });
    }
};


onMounted(() => {
  // query();
});


</script>
<style lang='scss' scoped>
</style>
